﻿using System;
using System.Windows.Forms;

namespace HanoiSimulator
{
    public partial class InitForm : Form
    {
        int returnNum;
        bool canClose;

        public InitForm()
        {
            InitializeComponent();
            canClose = false;
        }

        private void btnStart_Click(object sender, EventArgs e)
        {
            try
            {
                returnNum = Convert.ToInt32(txbFloorCount.Text);
                canClose = true;
                this.Close();
            }
            catch (Exception err)
            {
                MessageBox.Show("发生了一个异常。\n详细信息：" + err.Message);
            }
        }

        internal int GetFloorCount() { return returnNum; }

        private void InitForm_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (!canClose)
            {
                Environment.Exit(0);
            }
        }
    }
}
